home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3036 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.7 KB  |  117 lines

  1. Newsgroups: comp.lang.c
  2. Path: in2.uu.net!tellab5!news
  3. From: Joe Toth <toth@tellabs.com>
  4. Subject: Re: Segmentation fault at return statement. Can't figure out ....
  5. X-Nntp-Posting-Host: sunh25
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <1996Jan25.140906.6807@tellab5.tellabs.com>
  8. Sender: news@tellab5.tellabs.com (News)
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Tellabs Operations, Inc.
  11. References: <4dm2n1$egk@murphy.servtech.com> <4dop08$kdi@bcfreenet.seflin.lib.fl.us> <9601201829.AA02117@dxmint.cern.ch> <4e63p2$ljg@bcfreenet.seflin.lib.fl.us> <9601251253.AA14631@dxmint.cern.ch>
  12. Mime-Version: 1.0
  13. Date: Thu, 25 Jan 1996 14:09:06 GMT
  14. X-Mailer: Mozilla 1.1 (X11; U; SunOS 4.1.3 sun4c)
  15. X-Url: news:9601251253.AA14631@dxmint.cern.ch
  16.  
  17. Dan Pop <danpop@mail.cern.ch> wrote:
  18. >z007400b@bcfreenet.seflin.lib.fl.us (Ralph Silverman) writes:
  19. >
  20. >>Dan Pop (danpop@mail.cern.ch) wrote:
  21. >>: z007400b@bcfreenet.seflin.lib.fl.us (Ralph Silverman) writes:
  22. >>
  23. >>: >    'test'
  24. >>: >    is likely to be
  25. >>: >    a command of
  26. >>: >    the
  27. >>: >        operating system
  28. >>
  29. >>: So what?  There's no possible conflict/interaction between a function
  30. >>: name in a C program and the name of an OS command.
  31. >>
  32. >>: >    1)    look it up.
  33. >>: >    2)    rename yours.
  34. >>:                 ^^^^^^^^^^^^^
  35. >>: Why???
  36. >>
  37. >>        is it not possible
  38. >>        that the link order of
  39. >>        test.c etc.
  40. >>    resulted in an executable named
  41. >>    test.exe,
  42. >>    test.com
  43. >>    or such?
  44. >
  45. >On some systems, this may be possible, however, on the only system where
  46. >"test" is a command (that I know of), this is not possible. 
  47. >
  48. >No matter the name of the resulting executable, this cannot explain the
  49. >behaviour observed by the original poster.
  50. >
  51. >Dan
  52. >-- 
  53. >Dan Pop
  54. >CERN, CN Division
  55. >Email: danpop@mail.cern.ch 
  56. >Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  57.  
  58. Come on guys....
  59.  
  60. Lets give an answer that helps.
  61.  
  62.  
  63. On some systems, 'test' is a builtin command of the appropriate
  64. shell (csh, ksh, etc.).  On other systems, it is an executable.
  65.  
  66. In either case (which together cover all unix & DOS systems), the
  67. compile/link process doesn't ever look at system/shell commands or
  68. executables.
  69.  
  70. The compiler/linker resolve function calls on 'object' files.
  71.  
  72. If you want to invoke the 'test' executable (if there is one), you
  73. use a 'C' call something like;
  74.  
  75.         system ( "test <test parameters>" );
  76.  
  77. This is the only way to execute an executable.
  78.  
  79. A 'C' function reference to 'test' requires a definition of
  80. a function named 'test()'.  If it is not found in the local source,
  81. the linker will look for it in the 'object' files (possibly in an
  82. archive file) specified in the 'link' command.
  83.  
  84. So, as stated 'There's no possible conflict/interaction<...>'.
  85.  
  86. Back to the real problem....
  87.  
  88. The user did not show any of the code that was contained in 'test'
  89. other than the 'return(999)'.  My bet is that the error is in the
  90. missing code......
  91.  
  92. Possibly;
  93.    writing outside the bounds of a locally defined array.
  94.    misuse of a pointer.
  95.    any of a number of coding errors.
  96.  
  97. Something in the code probably wrote over the return pointer.
  98. IT DOES HAPPEN...................
  99. It all depends on how & where the return pointers are stored, as
  100. many systems don't protect the return pointer if it is in the
  101. local variable heap (or does yours use stacks).
  102. I've accidentally done it myself.
  103.  
  104. Without seeing the code, it is impossible to say exactly what 
  105. caused the problem.....
  106.  
  107. -- 
  108.   _  _  ___  --------------------------+---------------------------------
  109.   | / _  |    Joseph G. Toth Jr.       | Tellabs Operations, Inc.  
  110. \_| \_/  |                             | toth@tellabs.com
  111.  
  112. > Every program has at least one bug and can be shortened by at least
  113. > one instruction -- from which, by induction, it is evident that every
  114. > program can be reduced to one instruction that does not work.
  115. >                       -- Ken Arnold
  116.  
  117.